#!/bin/bash

# Apply patches
for file in ./patches/*; do
  patch -d LibreELEC.tv/ -p1 < "${file#*/}"
done

# Change dist build options to my preference.
sed -i \
  "s/GOLD_SUPPORT=\".*\"/GOLD_SUPPORT=\"no\"/g
  ; s/HARDENING_SUPPORT=\".*\"/HARDENING_SUPPORT=\"yes\"/g
  ; s/BLUETOOTH_SUPPORT=\".*\"/BLUETOOTH_SUPPORT=\"no\"/g
  ; s/AVAHI_DAEMON=\".*\"/AVAHI_DAEMON=\"no\"/g
  ; s/KODI_UPNP_SUPPORT=\".*\"/KODI_UPNP_SUPPORT=\"no\"/g
  ; s/KODI_OPTICAL_SUPPORT=\".*\"/KODI_OPTICAL_SUPPORT=\"no\"/g
  ; s/KODI_AIRPLAY_SUPPORT=\".*\"/KODI_AIRPLAY_SUPPORT=\"no\"/g
  ; s/KODI_AIRTUNES_SUPPORT=\".*\"/KODI_AIRTUNES_SUPPORT=\"no\"/g
  ; s/KODI_SAMBA_SUPPORT=\".*\"/KODI_SAMBA_SUPPORT=\"no\"/g
  ; s/WIRELESS_DAEMON=\".*\"/WIRELESS_DAEMON=\"\"/g
  ; s/SAMBA_SUPPORT=\".*\"/SAMBA_SUPPORT=\"no\"/g
  ; s/SAMBA_SERVER=\".*\"/SAMBA_SERVER=\"no\"/g
  ; s/SFTP_SERVER=\".*\"/SFTP_SERVER=\"no\"/g
  ; s/OPENVPN_SUPPORT=\".*\"/OPENVPN_SUPPORT=\"no\"/g
  ; s/WIREGUARD_SUPPORT=\".*\"/WIREGUARD_SUPPORT=\"no\"/g
  ; s/NTFS3G=\".*\"/NTFS3G=\"no\"/g
  ; s/INSTALLER_SUPPORT=\".*\"/INSTALLER_SUPPORT=\"no\"/g
  ; s/REMOTE_SUPPORT=\".*\"/REMOTE_SUPPORT=\"yes\"/g
  ; s/ADDITIONAL_DRIVERS=\".*\"/ADDITIONAL_DRIVERS=\"\"/g
  ; s/KODI_BLURAY_SUPPORT=\".*\"/KODI_BLURAY_SUPPORT=\"no\"/g
  ; s/BLURAY_BDPLUS_SUPPORT=\".*\"/BLURAY_BDPLUS_SUPPORT=\"no\"/g
  ; s/BLURAY_AACS_SUPPORT=\".*\"/BLURAY_AACS_SUPPORT=\"no\"/g
  ; s/DEFAULT_LINKER=\".*\"/DEFAULT_LINKER=\"bfd\"/g" \
  LibreELEC.tv/distributions/LibreELEC/options

